// eslint-disable-next-line
import { UserLayout, BasicLayout } from '@/layouts'

const RouteView = {
  name: 'RouteView',
  render: (h) => h('router-view')
}

export const asyncRouterMap = [
  {
    path: '/',
    name: 'index',
    component: BasicLayout,
    meta: { title: '首页' },
    redirect: '/form',
    children: [
      // 测试页
      {
        path: '/form',
        redirect: '/form/base-form',
        component: RouteView,
        meta: { title: '测试页', icon: 'form' },
        children: [
          {
            path: '/form/base-form',
            name: 'BaseForm',
            component: () => import(/* webpackChunkName: "form" */ '@/views/form/index'),
            meta: { title: '表单', keepAlive: true }
          },
          {
            path: '/list/table-list',
            name: 'TableListWrapper',
            component: () => import(/* webpackChunkName: "table" */ '@/views/form/TableList'),
            meta: { title: '表格', keepAlive: true }
          }
        ]
      },
      {
        path: '/shop/base',
        name: 'ShopBase',
        hideChildrenInMenu: true,
        redirect: '/shop/ShopPage',
        component: () => import(/* webpackChunkName: "shop" */ '@/views/shop/Index'),
        meta: { title: '店铺', keepAlive: true, hidden: true, icon: 'icon-mendian' },
        children: [
          {
            path: '/shop/ShopPage',
            name: 'ShopPage',
            component: () => import(/* webpackChunkName: "shop" */ '@/views/shop/page'),
            meta: { title: '店铺页面', hidden: true }
          },
          {
            path: '/shop/navigation',
            name: 'ShopNavigation',
            component: () => import(/* webpackChunkName: "shop" */ '@/views/shop/navigation'),
            meta: { title: '店铺导航', hidden: true }
          },
          {
            path: '/shop/ShopUser',
            name: 'ShopUser',
            component: () => import(/* webpackChunkName: "shop" */ '@/views/shop/ShopUser'),
            meta: { title: '用户中心', hidden: true }
          },
          {
            path: '/shop/ShopList',
            name: 'ShopList',
            component: () => import(/* webpackChunkName: "shop" */ '@/views/shop/list'),
            meta: { title: '列表模板', hidden: true }
          },
          {
            path: '/shop/ShopClass',
            name: 'ShopClass',
            component: () => import(/* webpackChunkName: "shop" */ '@/views/shop/class'),
            meta: { title: '分类模板', hidden: true }
          },
          {
            path: '/shop/ShopSearch',
            name: 'ShopSearch',
            component: () => import(/* webpackChunkName: "shop" */ '@/views/shop/searchFor'),
            meta: { title: '搜索页', hidden: true }
          },
          {
            path: '/shop/ShopColorSystem',
            name: 'ShopColorSystem',
            component: () => import(/* webpackChunkName: "shop" */ '@/views/shop/colorSystem'),
            meta: { title: '店铺色系', hidden: true }
          }
        ]
      },
      {
        path: '/orderPage',
        redirect: '/orderPage/base',
        component: RouteView,
        meta: { title: '订单', icon: 'icon-dingdanfenxi' },
        children: [
          {
            path: '/orderPage/base',
            name: 'orderPage',
            component: () => import(/* webpackChunkName: "table" */ '@/views/order/TableList'),
            meta: { title: '订单', keepAlive: true }
          }
        ]
      },
      {
        path: '/commodity',
        redirect: '/commodity/base',
        component: RouteView,
        meta: { title: '商品', icon: 'icon-shangpinliebiao' },
        children: [
          {
            path: '/commodity/base',
            name: 'Commodity',
            component: () => import(/* webpackChunkName: "table" */ '@/views/form/TableList'),
            meta: { title: '商品', keepAlive: true }
          }
        ]
      },

      // 异常页
      {
        path: '/exception',
        name: 'exception',
        component: RouteView,
        redirect: '/exception/403',
        hidden: true,
        meta: { title: '异常页', icon: 'warning' },
        children: [
          {
            path: '/exception/403',
            name: 'Exception403',
            component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/403'),
            meta: { title: '403' }
          },
          {
            path: '/exception/404',
            name: 'Exception404',
            component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/404'),
            meta: { title: '404' }
          },
          {
            path: '/exception/500',
            name: 'Exception500',
            component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/500'),
            meta: { title: '500' }
          }
        ]
      }
    ]
  },
  {
    path: '*', redirect: '/404', hidden: true
  }
]

/**
 * 基础路由
 * @type { *[] }
 */
export const constantRouterMap = [
  {
    path: '/user',
    component: UserLayout,
    redirect: '/user/login',
    hidden: true,
    children: [
      {
        path: 'login',
        name: 'login',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/Login')
      },
      {
        path: 'register',
        name: 'register',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/Register')
      },
      {
        path: 'register-result',
        name: 'registerResult',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/RegisterResult')
      },
      {
        path: 'recover',
        name: 'recover',
        component: undefined
      }
    ]
  },

  {
    path: '/404',
    component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/404')
  }

]
